﻿CREATE PROCEDURE dbo.GetTakeoutProvidersForNotification
/*
	(
		@parameter1 datatype = default value,
		@parameter2 datatype OUTPUT
	)
*/
AS
	
SELECT     Id, MenuID, PaymentSourceID, UserID, ExpirationTime, StartTime, MaximumOrders, TakeoutCharge, Instructions, AllowPayMeLater, [SiteID], 
                      Notified
FROM         dbo.TakeoutProvider
WHERE     (ExpirationTime > GETDATE()) AND (Notified = 0)


UPDATE dbo.TakeoutProvider SET Notified = 1 WHERE ID IN (SELECT Id
FROM         dbo.TakeoutProvider
WHERE     (ExpirationTime > GETDATE()) AND (Notified = 0))

/* SET NOCOUNT ON */
	RETURN


